/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package models;

import java.util.ArrayList;
import javax.swing.JOptionPane;

/**
 *
 * @author Ali
 */
public class LoginStorage {

    private static ArrayList<String> logList = new ArrayList();
    private boolean alarm;

    public LoginStorage() {
        System.out.println("model");
    }

    public boolean log(String input) {
        for (int i = 0; i < logList.size(); i++) {
            if (logList.get(i).equals(input)) {
                logList.remove(input);
                System.out.println("\nUser logs out: " + input);
                if (logList.isEmpty()) {
                    alarm = true;
                    JOptionPane.showMessageDialog(null, "Alarm is ON");
                }
                return false;
            }
        }
        logList.add(input);
        System.out.println("\nUser logs in: " + input);
        alarm = false;
        JOptionPane.showMessageDialog(null, "Alarm is OFF");
        return true;
    }

    public int getLoggedUsers() {
        return logList.size();
    }

    public ArrayList<String> getLogList() {
        return logList;
    }
}
